package com.uneed.activity;

import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.net.URLDecoder;

import com.uneed.widget.HcWebActivity;

public class WebActivity extends HcWebActivity
{
  private boolean openexternal;
  private String title;
  private String url;

  protected WebViewClient createWebViewClient()
  {
    return new MyWebViewClient();
  }

@Override
  public void onCreate(Bundle paramBundle)
  {
    boolean bool = false;
    super.onCreate(paramBundle);
    if (getIntent().getData() != null)
    {
      this.url = getIntent().getData().getQueryParameter("url");
      this.title = getIntent().getData().getQueryParameter("title");
      String str = getIntent().getData().getQueryParameter("openexternal");
      if ((!"1".equals(str)) && (!"true".equals(str)))
      {
        openexternal = bool;
        if (url != null)
          url = URLDecoder.decode(url);     
      }
      if (this.url == null) finish();
      webView.loadUrl(url);
      setTitle(this.title);
     }
    webView.loadUrl("http://www.haoshe.org/m/md28/member.php?act=login&op=passport_login&type=weibo&mobile=ios");
    setTitle("webtest");

  }

  @Override
  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if ((paramInt == 4) && (paramKeyEvent.getAction() == 1) && (this.webView.canGoBack()))
      this.webView.goBack();
    return super.onKeyDown(paramInt, paramKeyEvent);
  }

  public class MyWebViewClient extends DPWebViewClient
  { 
	  public MyWebViewClient() {  
	  }

	  @Override
	  public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString) {
	      if (!openexternal)
		        if (!paramString.equals(url))
		        	return super.shouldOverrideUrlLoading(paramWebView, paramString);
    	  openExternalUrl(paramString);
    	  return true;
	    } 
  }
}

